/*
 * $Id: SignalAgent.hpp 50 2009-02-10 05:48:05Z hyunghwan.chung $
 *
   Copyright 2005-2009 Chung, Hyung-Hwan.

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an  BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */

#ifndef _XP_BAS_SIGNALAGENT_CLASS_
#define _XP_BAS_SIGNALAGENT_CLASS_

#include <xp/types.h>
#include <xp/macros.h>
#include <xp/bas/signal.h>

XP_BEGIN_NAMESPACE2 (xp, bas)

class SignalAgent 
{
public:
	SignalAgent ();
	virtual ~SignalAgent ();

	int ignoreSignal     (int sig);
	int defaultifySignal (int sig);
	int manageSignal     (int sig, bool restart = false);

	int ignoreAllSignals     ();
	int defaultifyAllSignals ();
	int manageAllSignals     (bool restart = false);
	int reapplyAllSigActions (bool restart = false);

	virtual void handleSignal (int sig) {}

protected:
	static SignalAgent* instance;

	static void perform_proc (int sig);
	void perform_proc_two (int sig);
		
	int mask[NSIG + 1];
};

XP_END_NAMESPACE2 (xp, bas)

#endif
		
